const Koa = require('koa')
const app = new Koa()
const json = require('koa-json')
const bodyparser = require('koa-bodyparser')

// middlewares
app.use(bodyparser({
  enableTypes:['json', 'form', 'text']
}))
app.use(json())

// 对router进行重写
const Router = require('./src/lib/router')
// 定义路由
const router = new Router(require('./src/routes'))
// 注册路由
app.use(router.forKoa().routes())

app.listen(3000)

module.exports = app
